﻿@{
    Style.Require("jQueryUI_Orchard");
    Style.Require("NineSeas.Common");
    Style.Require("NineSeas.Reader");
    Style.Require("NineSeas.Authoring");
    Style.Require("NineSeas.Book.Chapters");

    Script.Require("NineSeas.Common");

    Layout.Title = T("Chapters of").Text + " " + ViewBag.Book.Name;
}
<div class="chapters-container">                
    @if (ViewBag.Chapters.Count == 0)
    {         
        <p>@T("This book don't have any chapter.")</p>
    } else { 
        <div class="chapter-items">               
        @for (var i = 0; i < ViewBag.Chapters.Count; i++)
        {
            dynamic chapter = ViewBag.Chapters[i];
        <div class="chapter-item @(i % 2 == 0 ? "" : "chapter-item-alternate")">
            <a href="@Url.Action("Delete", "Chapter", new {id = chapter.Id, ReturnUrl = Request.Url.PathAndQuery})" class="command-right delete" onclick="return confirm('@T("Are you sure you want to delete this chapter?")')">
                @T("Delete")
            </a>
            <a href="@Url.Action("ChapterMoveUp", "BookAdmin", new {@id = chapter.BookId, @chapterId = chapter.Id, @area = "NineSeas"})" class="command-right arrow-up">
                @T("Move Up")
            </a>
            <a href="@Url.Action("ChapterMoveDown", "BookAdmin", new {@id = chapter.BookId, @chapterId = chapter.Id, @area = "NineSeas"})" class="command-right arrow-down">
                @T("Move Down")
            </a>
            <a href="@Url.Action("EditChapter", "BookAdmin", new {@id = chapter.BookId, @chapterId = chapter.Id})" class="chapter-title authoring">
                @(!String.IsNullOrEmpty(chapter.Title) ? (chapter.SortOrder + 1) + ". " + chapter.Title : T("Chapter").Text + " " + (chapter.SortOrder + 1))
            </a>
            <div class="clear: both;"></div>     
        </div>
        }  
        </div>  
    }
    <div class="clear: both;"></div>
</div>